package models

import (
	"fmt"
	"rongyy/src/app"
)

type OccupationModel struct {
	Id   int64  `xorm:"pk autoincr" json:"id"`
	Code string `json:"code"`
	Name string `json:"name"`
}

func (rm *OccupationModel) TableName() string {
	return "occupation"
}

func (rm *OccupationModel) String() string {
	return fmt.Sprintf("userid")
}

func (rm *OccupationModel) Query() ([]OccupationModel, int64, error) {
	regs := make([]OccupationModel, 0)
	//local, _ := time.LoadLocation("Asia/Shanghai")
	//t := time.Now().In(local).Format("2006-01-02 15:04:05")
	s := app.DB().Table("occupation")
	total, err := s.Limit(99, 0).FindAndCount(&regs)
	if err != nil {
		return nil, 0, err
	}
	return regs, total, err
}
